<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<link href="<%=basePath %>ui/css/style.css" rel="stylesheet" type="text/css" />
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
	#allmap {width:1000px;height:80%;overflow: hidden;margin:0;font-family:"微软雅黑";margin:0px auto;float: left}
	</style>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=AkgAI8t8n9EuiX3G8SFRajxl"></script>
	<title>地图展示</title>
</head>
<body>
 <%@ include file="/common/top.jsp" %> 
	<div class="container"><div id="allmap"></div></div>
	<%@ include file="/common/foot.jsp" %>
</body>
</html>
<script type="text/javascript">
    var index=3;
	var mapList=${mapList};
 	var map = new BMap.Map("allmap");    // 创建Map实例
	var point=new BMap.Point(${entity.dishUrl});
	map.centerAndZoom(point, 20);  // 初始化地图,设置中心点坐标和地图级别
	addMarker(point,"${entity.dishName}");
	  $(mapList).each(function(){
		var mp=this.dishUrl;
		if(mp != "${entity.dishUrl}"){
			var array=mp.split(",");
			addMarker(new BMap.Point(array[0],array[1]),this.dishName);
		}
	});  
	map.addControl(new BMap.MapTypeControl());   //添加地图类型控件
	map.setCurrentCity("郑州");          // 设置地图显示的城市 此项是必须设置的
	map.enableScrollWheelZoom(true);      //开启鼠标滚轮缩放
	
	// 随机向地图添加25个标注
/*  	var bounds = map.getBounds();
	var sw = bounds.getSouthWest();
	var ne = bounds.getNorthEast();
	var lngSpan = Math.abs(sw.lng - ne.lng);
	var latSpan = Math.abs(ne.lat - sw.lat);
	for (var i = 0; i < 25; i ++) {
		console.log(i+"==============="+sw.lng + lngSpan * (Math.random() * 0.7), ne.lat - latSpan * (Math.random() * 0.7));
		var point = new BMap.Point(sw.lng + lngSpan * (Math.random() * 0.7), ne.lat - latSpan * (Math.random() * 0.7));
	    addMarker(point,i+"随机测试");
	} */
	 
	function addMarker(point,name){
		  var marker=new BMap.Marker(point);
			map.addOverlay(marker);
			var label = new BMap.Label(name,{offset:new BMap.Size(20,-10)});
			marker.setLabel(label);
	}
</script>
